package com.ynny.bookmanagersystem.controller;

import com.ynny.bookmanagersystem.dao.UserDao;
import com.ynny.bookmanagersystem.dao.UserDaoImpl;
import com.ynny.bookmanagersystem.entity.User;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/user/editUser")
public class EditUserServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request,
                           HttpServletResponse response) throws ServletException, IOException {

        String id = request.getParameter("id");

        UserDao userDao = new UserDaoImpl();

        User user = userDao.selectUserById(Integer.parseInt(id));

        request.setAttribute("user", user);

        request.getRequestDispatcher("/user/updateUser.jsp")
                .forward(request, response);



    }
}
